<?php

	include("common.php");
	
	if(!isset($_SESSION['tusername'])) exit;
	
	if(!empty($_POST)){
		mysql_query("UPDATE `197_teacherdata` SET `title` = '" . $_POST['title'] . "', `content` = '" . $_POST['content'] . "' WHERE `teacherdata_id` = " . $_POST['teacherdata_id']);
		include("header.php");
?>
<h1>修改資料</h1>
<p>修改成功，請<a href="teacherDataFind.php">按此</a>返回。</p>
<?php

		include("sidebar.php");
		include("footer.php");
		
		exit;
	
	}
	
	$result = mysql_query("SELECT * FROM `197_teacherdata` WHERE `teacherdata_id` = " . $_GET['teacherdata_id']);
	$row = mysql_fetch_assoc($result);
	
?>
<?php include("header.php"); ?>
<h1>編輯資料</h1>
<script type="text/javascript">
	$(function(){
		$('textarea.tinymce').tinymce({
			// Location of TinyMCE script
			script_url : './jquery/tiny_mce/tiny_mce.js',

			// General options
			theme : "advanced",
			plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist",

			// Theme options
			theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,formatselect,fontselect,fontsizeselect",
			theme_advanced_buttons2 : "cut,copy,paste,|,search,replace,|,bullist,numlist,|,blockquote,|,undo,redo,|,link,unlink,image,code,styleprops,forecolor,backcolor",
			theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,charmap,emotions,iespell,media,|,print,|,fullscreen",
			theme_advanced_buttons4 : "",
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			theme_advanced_statusbar_location : "bottom",
			theme_advanced_resizing : true,

			// Drop lists for link/image/media/template dialogs
			template_external_list_url : "lists/template_list.js",
			external_link_list_url : "lists/link_list.js",
			external_image_list_url : "lists/image_list.js",
			media_external_list_url : "lists/media_list.js",
		});
	});
</script>
<form action="teacherDataEdit.php" method="POST">
	<p><label>標題：<input type="text" name="title" value="<?php echo $row['title']; ?>" /></label></p>
	<textarea class="tinymce" name="content" style="width: 500px;"><?php echo $row['content']; ?></textarea>
	<p><input type="submit" value="編輯" />｜<a href="teacherDataFind.php">返回</a></p><input type="hidden" name="teacherdata_id" value="<?php echo $_GET['teacherdata_id']; ?>" />
</form>
<?php include("sidebar.php"); ?>
<?php include("footer.php"); ?>